package gemini.castor.ui.client.page.content.home.register.confirminfo;

import gemini.castor.ui.client.constants.I18nConstants;
import gemini.castor.ui.client.utils.GuiUtils;

import java.util.Map;

import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.HasClickHandlers;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.uibinder.client.UiTemplate;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.Panel;
import com.google.gwt.user.client.ui.Widget;

public class ConfirmInfoFormView extends Composite implements
		ConfirmInfoFormPresenter.Display {

	@UiTemplate("ConfirmInfoFormView.ui.xml")
	interface MyUiBinder extends UiBinder<Panel, ConfirmInfoFormView> {
	}
	
	private ConfirmInfoFormObject object;
	private static final MyUiBinder binder = GWT.create(MyUiBinder.class);
	private I18nConstants constants;
	
	public ConfirmInfoFormView() {
		initWidget(binder.createAndBindUi(this));
		constants = GWT.create(I18nConstants.class);
	}

	@UiField
	HTML htmDistributorId;

	@UiField
	HTML htmFullName;
	
	@UiField
	HTML htmUserName;
	
	@UiField
	HTML htmEmail;
	
	@UiField
	HTML htmLanguage;

	@UiField
	Button btnConfirm;

	@UiField
	Button btnBack;
	
	@UiField
	Button btnCancel;

	@Override
	public void loadData() {
		htmDistributorId.setHTML(object.getDistributorCode());
		htmEmail.setHTML(object.getEmail());
		htmFullName.setHTML(object.getFullName());
		Map<String,String> map = GuiUtils.getValueFromConstant(constants.stringLanguage());
		htmLanguage.setHTML(map.get("vi"));
		
		htmUserName.setHTML(object.getUser().getUsername());
	}

	@Override
	public Widget asWidget() {
		return this;
	}

	@Override
	public HasClickHandlers getConfirmClickHandlers() {
		return btnConfirm;
	}
	
	@Override
	public HasClickHandlers getBackClickHandlers() {
		return btnBack;
	}

	@Override
	public HasClickHandlers getCancelClickHandlers() {
		return btnCancel;
	}

	@Override
	public void setObject(ConfirmInfoFormObject inputObject) {
		this.object = inputObject;
	}
}
